$(document).ready(function(){
	
	//Check to see if the window is top if not then display button
	$(window).scroll(function(){
		if ($(this).scrollTop() > 100) {
			$('.scrollToTop').fadeIn();
		} else {
			$('.scrollToTop').fadeOut();
		}
	});
	
	//Click event to scroll to top
	$('.scrollToTop').click(function(){
		$('html, body').animate({scrollTop : 0},0);
		return false;
	});
	
	$(document).click(function(e) {
		var target = $(e.target);
		if(!target.is('menu-item') && !target.is('.rmm-button')){
			var maintoggled = $('.rmm-toggled');
			if (!maintoggled.is(".rmm-closed")) {
				maintoggled.find('ul').stop().hide(300);
		 		maintoggled.addClass("rmm-closed");
			}
		}
	});
	
});